{template 'common/header'}
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>
<ul class="nav nav-tabs">
  <li {if $opp == 'chainsetup'}class="active"{/if}><a href="{php echo $this->createWebUrl('chainsetup');}">外链基本设置</a></li>
  <li {if $opp == 'chains'}class="active"{/if}><a href="{php echo $this->createWebUrl('chains');}">外链管理</a></li>
  <li {if $opp == 'chainsbanner'}class="active"{/if}><a href="{php echo $this->createWebUrl('chainsbanner');}">外链幻灯片管理</a></li>
</ul>
</div>
<ul class="nav nav-tabs">
	<li {if $operation == 'display'} class="active" {/if}><a href="{php echo $this->createWebUrl('chains',array('op' =>'display'))}">外链列表</a></li>
	<li{if empty($chains['id']) && $operation == 'post'} class="active" {/if}><a href="{php echo $this->createWebUrl('chains',array('op' =>'post'))}">添加外链</a></li>
	{if !empty($chains['id']) &&  $operation == 'post'}<li  class="active"><a href="{php echo $this->createWebUrl('chains',array('op' =>'post','id'=>$chains['id']))}">编辑外链</a></li>{/if}
</ul>
{if $operation == 'display'}
<div class="panel panel-success">
  <div class="panel-heading">外链页面 >外链管理</div>
</div>
<div class="main panel panel-default">

	<div class="panel-body table-responsive">

		<table class="table table-hover">

			<thead class="navbar-inner">

				<tr>

					<th style="width:30px;">ID</th>

					<th>显示顺序</th>					

					<th>小程序或网页名称</th>

					<th>外链类型</th>

					<th >操作</th>

				</tr>

			</thead>

			<tbody>

				{loop $list $banner}

				<tr>

					<td>{$banner['id']}</td>

					<td>{$banner['displayorder']}</td>

					<td>{$banner['chain_name']}</td>

					<td>
                    {if $banner['akey']=='0'}
                        <span class="label label-info">小程序</span>
                        {elseif $banner['akey']==1}
                        <span class="label label-success">外链网页</span>
                        {elseif $banner['akey']==2}
                        <span class="label label-success">二维码</span>
                        {/if}
                    
                    </td>

					<td style="text-align:left;">

						<a href="{php echo $this->createWebUrl('chains', array('op' => 'post', 'id' => $banner['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>

						<a href="{php echo $this->createWebUrl('chains', array('op' => 'delete', 'id' => $banner['id']))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>

					</td>

				</tr>

				{/loop}

			</tbody>

		</table>

		{$pager}

	</div>

</div>

<script>

	require(['bootstrap'],function($){

		$('.btn').hover(function(){

			$(this).tooltip('show');

		},function(){

			$(this).tooltip('hide');

		});

	});

</script>

{elseif $operation == 'post'}

<div class="main">

	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>

		<input type="hidden" name="id" value="{$chains['id']}" />

		<div class="panel panel-default">

			<div class="panel-heading">

				外链设置

			</div>

			<div class="panel-body">
            
            <div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">外链类型</label>

					<div class="col-sm-9 col-xs-12">

						<label class='radio-inline'>

							<input type='radio' name='akey' value='0' {if $chains['akey']==0}checked{/if} /> 同公众号下小程序

						</label>

						<label class='radio-inline'>

							<input type='radio' name='akey' value='1' {if $chains['akey']==1}checked{/if} /> 外部网页（https，小程序后台授权）

						</label>
                        
                        <label class='radio-inline'>

							<input type='radio' name='akey' value='2' {if $chains['akey']==2}checked{/if} /> 小程序二维码（非同公众号）

						</label>

					</div>

				</div>

				<div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>

					<div class="col-sm-9 col-xs-12">

						<input type="text" name="displayorder" class="form-control" value="{$chains['displayorder']}" />

					</div>

				</div>

				<div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label"></span>小程序或网页名称</label>

					<div class="col-sm-9 col-xs-12">

						<input type="text" id='chain_name' name="chain_name" class="form-control" value="{$chains['chain_name']}" />

					</div>

				</div>

				<div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">略图图标</label>

					<div class="col-sm-9 col-xs-12">

						{php echo tpl_form_field_image('thumb', $chains['thumb'])}
                        
                          <span class="help-block">图片比例：200：200</strong></span>
                        

					</div>

				</div>
                
                <div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">外链小程序appid</label>

					<div class="col-sm-9 col-xs-12">

						<input type="text" name="wx_appid" class="form-control" value="{$chains['wx_appid']}" />
                        <font style="color:red;"></font>
             <span class="help-block"><font style="color:red;">打开同一公众号下关联的另一个小程序。（注：必须是同一公众号下，而非同个 open 账号下）</font></strong></span>
					</div>

				</div>
               <div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">外链小程序页面地址</label>

					<div class="col-sm-9 col-xs-12">

						<input type="text" name="wx_path" class="form-control" value="{$chains['wx_path']}" />
                        
                        <span class="help-block">跳转到小程序哪个页面，留空默认外部小程序首页；如外链网页则填写全网址；</strong></span>

					</div>

				</div>
                <div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label">小程序二维码</label>

					<div class="col-sm-9 col-xs-12">

						{php echo tpl_form_field_image('mqrcode', $chains['mqrcode'])}
                        

					</div>

				</div>
                <div class="form-group">

					<label class="col-xs-12 col-sm-3 col-md-2 control-label"></span>小程序或网页描述</label>

					<div class="col-sm-9 col-xs-12">

						<input type="text" id='describe' name="describe" class="form-control" value="{$chains['describe']}" />

					</div>

				</div>

			</div>

		</div>

<div class="form-group col-sm-12">

	<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />

	<input type="hidden" name="token" value="{$_W['token']}" />

	</div>

	</form>

</div>




<script language='javascript'>

	function formcheck() {

		if ($("#chain_name").isEmpty()) {

			Tip.focus("chain_name", "请填写外链名称!");

			return false;

		}

		return true;

	}

</script>

{/if}

{template 'common/footer'}